/*
 * @Author: dark-snow 1306808708@qq.com
 * @Date: 2023-07-04 16:57:50
 * @LastEditors: dark-snow 1306808708@qq.com
 * @LastEditTime: 2023-07-06 11:14:18
 * @FilePath: \wifi_server_030704\components\user_component\include\user_wifi.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

#ifndef _USER_WIFI_H_
#define _USER_WIFI_H_

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"

#include "esp_mac.h"
#include "esp_system.h"
#include "esp_log.h"
#include "esp_wifi.h"

#include "lwip/err.h"
#include "lwip/sys.h"
#include "sys/socket.h"

#include "user_socket.h"

// modifiable define

#define USER_WIFI_AP_DEFAULT_NETMASK "255.255.255.0"

// const define
#define WIFI_AP_START_BIT BIT0
#define WIFI_AP_STOP_BIT BIT1
#define WIFI_AP_SOFT_START_BIT BIT2
#define WIFI_AP_REBOOT_BIT BIT3
#define USER_WIFI_AP_INHERENT_CONFIG(softap_ip)                                      \
	{                                                                                \
		.flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \
		ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(mac)                       \
			.ip_info = &softap_ip,                                                   \
		.get_ip_event = 0,                                                           \
		.lost_ip_event = 0,                                                          \
		.if_key = "WIFI_AP_DEF",                                                     \
		.if_desc = "ap",                                                             \
		.route_prio = 10,                                                            \
		.bridge_info = NULL,                                                         \
	}

extern EventGroupHandle_t s_wifi_event_group;
extern char my_wifi_ssid[32];
extern char my_wifi_pass[64];
extern char my_wifi_ap_ip[16];

void wifi_app_task(void *pt);
void user_wifi_ap_start(char *ip);
void user_wifi_ap_restore(void);
void user_wifi_ap_stop(void);
void user_wifi_get_ip(esp_netif_t *esp_netif);

#endif